{% extends "../../../layui/layouts/blank.html" %}

{% block mainbody %}
<div class="view-block">
    <table class="layui-table">
        <tbody>
        <tr>
            <td>上报编号</td>
            <td>{{report.number}}</td>
        </tr>
        <tr>
            <td>产品名称</td>
            <td>{{report.produce_name}}</td>
        </tr>
        <tr>
            <td>公司名称</td>
            <td>{{report.company_name}}</td>
        </tr>
        <tr>
            <td>上报时间</td>
            <td>{{report.reported_at}}</td>
        </tr>
        <tr>
            <td>上报人</td>
            <td>{{report.username}}</td>
        </tr>
        <tr>
            <td>上报单位</td>
            <td>{{report.unit}}</td>
        </tr>
        <tr>
            <td>所属地区</td>
            <td>{{report.address}}</td>
        </tr>
        <tr>
            <td>联系电话</td>
            <td>{{report.phone}}</td>
        </tr>
        <tr>
            <td>风险描述</td>
            <td>
                <table >
                    {% for key, item in  report.risk_desc %}
                    <tr>
                        <td>{{key}}</td>
                        <td>
                            <table>
                                {% for v in item %}
                                {% if v.AnnexType == 0 %}
                                <tr><td>{{v.Src}}</td></tr>
                                {% elif v.AnnexType == 1 %}
                                <tr><td><img src="/{{v.Src}}" alt=""></td></tr>
                                {% elif v.AnnexType == 2 %}
                                <tr><td><a href="/{{v.Src}}" alt="">下载word</a></td></tr>
                                {% elif v.AnnexType == 3 %}
                                <tr><td><a href="/{{v.Src}}" alt="">下载pdf</a></td></tr>
                                {% endif %}
                                {% endfor %}
                            </table>

                        </td>
                    </tr>
                    {% endfor %}
                </table>
            </td>
        </tr>
        <tr>
            <td>风险分析</td>
            <td>
                <table >
                    {% for key, item in  report.risk_analysis %}
                    <tr>
                        <td>{{key}}</td>
                        <td>
                            <table>
                                {% for v in item %}
                                {% if v.AnnexType == 0 %}
                                <tr><td>{{v.Src}}</td></tr>
                                {% elif v.AnnexType == 1 %}
                                <tr><td><img src="/{{v.Src}}" alt=""></td></tr>
                                {% elif v.AnnexType == 2 %}
                                <tr><td><a href="/{{v.Src}}" alt="">下载word</a></td></tr>
                                {% elif v.AnnexType == 3 %}
                                <tr><td><a href="/{{v.Src}}" alt="">下载pdf</a></td></tr>
                                {% endif %}
                                {% endfor %}
                            </table>

                        </td>
                    </tr>
                    {% endfor %}
                </table>
            </td>
        </tr>

        </tbody>

        <tfoot>
        <tr>
            <td colspan="2" style="text-align: center">
                <a class="layui-btn layui-btn-info layui-btn" yak-event="watch" data-id="{{report.id}}">关注</a>
                <a class="layui-btn layui-btn-danger layui-btn" yak-event="unwatch" data-id="{{report.id}}">不关注</a>
            </td>
        </tr>
        </tfoot>

    </table>
</div>
{% endblock %}

{% block view_event %}
<script>
    var YAK_EVENTS = {
        watch: function (othis, setter, view) {
            var helper = layui.helper, $ax = layui.ax, layer = layui.layer, id = othis.attr('data-id')
            layer.prompt({
                formType: 2,  value: '无',  maxlength: 500,  title: '请输入风险评估'
            }, function (value, index, elem) {
                var url = "/report-watch",
                ajax = new $ax(url, function (res) {
                    layer.close(index)
                    parent.window.location.reload()
                });
                ajax.setMethod('post')
                ajax.setData({comment: value, id: id});
                ajax.send();
            });
        },
        unwatch: function (othis, setter, view) {
            var helper = layui.helper, $ax = layui.ax, layer = layui.layer, id = othis.attr('data-id')
            layer.prompt({
                formType: 2,  value: '无',  maxlength: 500,  title: '请输入风险评估'
            }, function (value, index, elem) {
                var url = "/report-unwatch",
                    ajax = new $ax(url, function (res) {
                        layer.close(index)
                        parent.window.location.reload()
                    });
                ajax.setMethod('post')
                ajax.setData({comment: value, id: id});
                ajax.send();
            });
        },
    }
</script>
{% endblock %}